Micron Document
<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Adaptive replacement cache</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Adaptive_replacement_cache"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Adaptive_replacement_cache rootpage-Adaptive_replacement_cache skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Adaptive replacement cache</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr"><p>
<b>Adaptive Replacement Cache</b> (<b>ARC</b>) is a <a href="Page_replacement_algorithm" title="Page replacement algorithm">page replacement algorithm</a> with
better performance<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup> than <a href="Cache_algorithms" class="mw-redirect" title="Cache algorithms">LRU</a> (least recently used). This is accomplished by keeping track of both frequently used and recently used pages plus a recent eviction history for both. The algorithm was developed<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> at the IBM <a href="Almaden_Research_Center" class="mw-redirect" title="Almaden Research Center">Almaden Research Center</a>. In 2006, IBM was granted a <a rel="nofollow" class="external text" href="https://web.archive.org/web/20170624055115/http://patft1.uspto.gov/netacgi/nph-Parser?patentnumber=6996676">patent for the adaptive replacement cache policy</a>.
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="Summary">Summary</h2></div>
<p>Basic LRU maintains an ordered list (the cache directory) of resource entries in the cache, with the sort order based on the time of most recent access. New entries are added at the top of the list, after the bottom entry has been evicted. Cache hits move to the top, pushing all other entries down.
</p><p>ARC improves the basic LRU strategy by splitting the cache directory into two lists, T1 and T2, for recently and frequently referenced entries. In turn, each of these is extended with a <i>ghost</i> list (B1 or B2), which is attached to the bottom of the two lists. These <i>ghost</i> lists act as scorecards by keeping track of the history of recently evicted cache entries, and the algorithm uses <i>ghost</i> hits to adapt to recent change in resource usage. Note that the <i>ghost</i> lists only contain metadata (keys for the entries) and not the resource data itself, i.e. as an entry is evicted into a <i>ghost</i> list its data is discarded. The combined cache directory is organised in four LRU lists:
</p>
<ol><li>T1, for recent cache entries.</li>
<li>T2, for frequent entries, referenced at least twice.</li>
<li>B1, <i>ghost</i> entries recently evicted from the T1 cache, but are still tracked.</li>
<li>B2, similar <i>ghost</i> entries, but evicted from T2.</li></ol>
<p>T1 and B1 together are referred to as L1, a combined history of recent single references.
Similarly, L2 is the combination of T2 and B2.
</p><p>The whole cache directory can be visualised in a single line:
</p>
<pre>. . . <b>[</b> B1 &lt;-<b>[</b> T1 &lt;-<b>!</b>-&gt; T2 <b>]</b>-&gt; B2 <b>]</b> . .
<b>[</b> . . . . <b>[</b> . . . . . . <b>!</b> . .<b>^</b>. . . . <b>]</b> . . . . <b>]</b>
<b>[</b> fixed cache size (c) <b>]</b>
</pre>
<p>The inner <b>[</b> <b>]</b> brackets indicate actual cache, which although fixed in size, can move freely across the B1 and B2 history.
</p><p>L1 is now displayed from right to left, starting at the top, indicated by the <b>!</b> marker. <b>^</b> indicates the target size for T1, and may be equal to, smaller than, or larger than the actual size (as indicated by <b>!</b>).
</p>
<ul><li>New entries enter T1, to the left of <b>!</b>, and are gradually pushed to the left, eventually being evicted from T1 into B1, and finally dropped out altogether.</li>
<li>Any entry in L1 that gets referenced once more, gets another chance, and enters L2, just to the right of the central <b>!</b> marker. From there, it is again pushed outward, from T2 into B2. Entries in L2 that get another hit can repeat this indefinitely, until they finally drop out on the far right of B2.</li></ul>
<div class="mw-heading mw-heading3"><h3 id="Replacement">Replacement</h3></div>
<p>Entries (re-)entering the cache (T1, T2) will cause <b>!</b> to move towards the target marker <b>^</b>. If no free space exists in the cache, this marker also determines whether either T1 or T2 will evict an entry.
</p>
<ul><li>Hits in B1 will increase the size of T1, pushing <b>^</b> to the right. The last entry in T2 is evicted into B2.</li>
<li>Hits in B2 will shrink T1, pushing <b>^</b> back to the left. The last entry in T1 is now evicted into B1.</li>
<li>A cache miss will not affect <b>^</b>, but the <b>!</b> boundary will move closer to <b>^</b>..</li></ul>
<div class="mw-heading mw-heading2"><h2 id="Deployment">Deployment</h2></div>
<p>ARC is currently deployed in IBM's DS6000/<a href="IBM_DS8000" class="mw-redirect" title="IBM DS8000">DS8000</a> storage controllers.
</p><p><a href="Sun_Microsystems" title="Sun Microsystems">Sun Microsystems</a>'s scalable file system <a href="ZFS" title="ZFS">ZFS</a> uses a variant<sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup> of ARC as an alternative to the traditional <a href="Solaris_(operating_system)" class="mw-redirect" title="Solaris (operating system)">Solaris</a> filesystem page cache in virtual memory. It has been modified to allow for locked pages that are currently in use and cannot be vacated.
</p><p><a href="PostgreSQL" title="PostgreSQL">PostgreSQL</a> used ARC in its buffer manager for a brief time (version 8.0.0), but quickly replaced it with another algorithm,
citing concerns over an IBM patent on ARC.<sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup>
</p><p><a href="VMware" title="VMware">VMware</a>'s vSAN (formerly Virtual SAN) is a hyper-converged, software-defined storage (SDS) product developed by VMware. It uses A variant of ARC in its Caching Algorithm. <sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup>
</p><p><a href="OpenZFS" title="OpenZFS">OpenZFS</a> supports using ARC and L2ARC in a <a href="Multi-level_cache" class="mw-redirect" title="Multi-level cache">multi-level cache</a> as read caches.
In OpenZFS, disk reads often hit the first level disk cache in RAM using ARC.
If a SSD is set up to store the second level disk cache, it is called an L2ARC. L2ARC uses the same ARC algorithm, but instead of storing the cached data in RAM, L2ARC stores the cached data in a fast SSD.<sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-7" class="reference"><a href="#cite_note-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-9" class="reference"><a href="#cite_note-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-10" class="reference"><a href="#cite_note-10"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-11" class="reference"><a href="#cite_note-11"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<ul><li><a href="Clock_with_Adaptive_Replacement" class="mw-redirect" title="Clock with Adaptive Replacement">Clock with Adaptive Replacement</a></li>
<li><a href="LIRS_caching_algorithm" title="LIRS caching algorithm">LIRS caching algorithm</a></li></ul>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<div class="mw-references-wrap mw-references-columns"><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text">One Up on LRU, <a rel="nofollow" class="external text" href="https://www.usenix.org/publications/login/august-2003-volume-28-number-4/one-lru">Usenix :login; August 2003</a></span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text"><a href="Nimrod_Megiddo" title="Nimrod Megiddo">Nimrod Megiddo</a> and <a href="Dharmendra_Modha" title="Dharmendra Modha">Dharmendra Modha</a>, <a rel="nofollow" class="external text" href="https://web.archive.org/web/20100329071954/http://www.almaden.ibm.com/StorageSystems/projects/arc/">2010-03-09 archive of the ARC home page</a>, with pointers to several articles</span>
</li>
<li id="cite_note-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-3">^</a></b></span> <span class="reference-text">comments in Solaris ZFS <a rel="nofollow" class="external text" href="https://archive.today/20130703061815/http://java.net/projects/solaris/sources/on-src/content/usr/src/uts/common/fs/zfs/arc.c?rev=13149">arc.c </a> source file explains differences with original work</span>
</li>
<li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text">Article in Postgresql General Bits, <a rel="nofollow" class="external text" href="https://archive.today/20130205145832/http://www.varlena.com/GeneralBits/96.php">"The Saga of the ARC Algorithm and Patent"</a>, published 6 February 2005</span>
</li>
<li id="cite_note-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-5">^</a></b></span> <span class="reference-text">Reference document, <a rel="nofollow" class="external text" href="https://www.storagehub.vmware.com/t/vmware-vsan/vmware-vsan-caching-algorithms/">"VMware vSAN Caching Algorithms"</a></span>
</li>
<li id="cite_note-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-6">^</a></b></span> <span class="reference-text">
<a rel="nofollow" class="external text" href="https://www.45drives.com/community/articles/zfs-caching/">"ZFS Caching"</a>.</span>
</li>
<li id="cite_note-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-7">^</a></b></span> <span class="reference-text">
<a rel="nofollow" class="external text" href="https://www.ixsystems.com/documentation/freenas/11.3-U5/zfsprimer.html">"ZFS Primer"</a>.</span>
</li>
<li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text">
Jim Salter.
<a rel="nofollow" class="external text" href="https://arstechnica.com/gadgets/2020/02/zfs-on-linux-should-get-a-persistent-ssd-read-cache-feature-soon/">"Persistent L2ARC might be coming to ZFS on Linux"</a>.
2020.</span>
</li>
<li id="cite_note-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-9">^</a></b></span> <span class="reference-text">
<a rel="nofollow" class="external text" href="https://docs.oracle.com/cd/E27998_01/html/E48490/analytics__statistics__cache_l2arc_accesses.html">"Cache: L2ARC accesses"</a>.</span>
</li>
<li id="cite_note-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-10">^</a></b></span> <span class="reference-text">
Brendan Gregg.
<a rel="nofollow" class="external text" href="http://www.brendangregg.com/blog/2008-07-22/zfs-l2arc.html">"ZFS L2ARC"</a>.</span>
</li>
<li id="cite_note-11"><span class="mw-cite-backlink"><b><a href="#cite_ref-11">^</a></b></span> <span class="reference-text">
Ranvir Singh.
<a rel="nofollow" class="external text" href="https://linuxhint.com/configuring-zfs-cache/">"Adaptive Replacement Cache (ARC) and L2ARC"</a>.</span>
</li>
</ol></div>
<div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2></div>
<ul><li><a rel="nofollow" class="external text" href="http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.13.5210">ARC: A Self-Tuning, Low Overhead Replacement Cache (2003) by Nimrod Megiddo, Dharmendra Modha</a></li>
<li><a rel="nofollow" class="external text" href="http://linux-mm.org/AdvancedPageReplacement">Linux Memory Management Wiki</a></li>
<li>Bourbonnais, Roch. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20120902124517/https://blogs.oracle.com/roch/date/20060621">ZFS Dynamics</a></li>
<li><a rel="nofollow" class="external text" href="http://code.activestate.com/recipes/576532/">Python implementation, recipe 576532</a></li>
<li><a rel="nofollow" class="external text" href="http://www.cs.biu.ac.il/~wiseman/2os/2os/os2.pdf">Comparison of LRU, ARC and others</a></li></ul></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2024-12-16" href="https://en.wikipedia.org/wiki/?title=Adaptive_replacement_cache&amp;oldid=1263388679">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>

</body></html>